<template>
  <div class="app-container calendar-list-container">
    <div class="apply-query">
      <el-row class="filter-query">
        <el-col><span>{{$t('projectRevenue.dataReport.queryCondition')}}</span></el-col>
      </el-row>
      <el-form :inline="true" :model="listQuery" style="padding: 0 20px">
        <el-row style="padding-bottom: 10px">
          <el-col :span="4">
            <div class="w20">
              <div class="labelName">{{$t('projectRevenue.dataReport.projectNo')}}</div>
              <el-input class="filter-item" v-model="listQuery.projectCode" clearable :placeholder="$t('placeholder.content')"></el-input>
            </div>
          </el-col>
          <el-col :span="4">
            <div class="w20">
              <div class="labelName">Year</div>
              <dict-select v-model="listQuery.dataYear" code="year" :clearable="true"></dict-select>
            </div>
          </el-col>
          <el-col :span="4" style="margin-top: 32px">
            <div type="primary" class="yt-btn yt-btn-ys" @click="handleFilter">{{$t('button.query')}}</div>
            <div type="primary" class="yt-btn yt-ml8" @click="reset">{{$t('button.reset')}}</div>
          </el-col>
        </el-row>
      </el-form>
    </div>

    <div class="yt-data-list" style="padding-bottom: 20px;" v-loading="loading" :element-loading-text="$t('projectRevenue.dataReport.loading')" element-loading-spinner="el-icon-loading">
      <div class="yt-list-title">
        <span>{{$t('projectRevenue.dataReport.listTile')}}</span>
      </div>
      <div class="yt-list-content">
        <div class="list-operation">
          <!--新增-->
          <el-button type="primary" class="yt-btn-ys" @click="dictDialogVisible = true">{{ $t("button.new") }}</el-button>
          <!--保存-->
          <el-button type="primary" class="yt-btn" @click="saveData">{{$t("button.preserve") }}</el-button>
          <!--删除-->
          <el-button type="primary" class="yt-btn" @click="deleteData">{{$t("button.delete") }}</el-button>
        </div>
        <el-table :data="list" :empty-text="$t('placeholder.emptyText')" border class="yt-table" @selection-change="handleSelectionChange" style="width: 100%" max-height="600">
          <!-- <el-table-column type="index" align="center" :label="$t('projectRevenue.dataReport.serialNum')" min-width="60"/> -->

            <el-table-column align="center" label="Sum" width="120" fixed>
              <el-table-column type="selection" align="center" class-name="pd" prop="id" width="60"/>
              <el-table-column type="index" align="center" :label=" $t('project.serialNumber')" class-name="pd" width="60"></el-table-column>
            </el-table-column>

          <el-table-column align="center" label="Year" prop="dataYear"  min-width="100" :show-overflow-tooltip="true" fixed />
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.projectNo')" prop="projectCode"  min-width="100" :show-overflow-tooltip="true" fixed/>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.projectName')" prop="projectName" min-width="300" :show-overflow-tooltip="true" fixed/>


            <!--type -->
         <el-table-column align="center" label="Type" width="100"  prop="Type">
            <template slot-scope="scope">
                <dict-select v-model="scope.row.projectType" code="projectType" clearable></dict-select>
            </template>
          </el-table-column>

          <!--專案负责人 -->
         <el-table-column align="center" :label="$t('projectRevenue.dataReport.projectEngineer')" width="220"  prop="projectEngineerName">
            <template slot-scope="scope">
              <popover-select selectType="user" @input="select" v-model="scope.row.projectEngineerName"  :placeholder="$t('placeholder.searchKeywords')"></popover-select>
            </template>
          </el-table-column>

            <!--客戶簡稱 -->
          <el-table-column align="center" :label="$t('projectRevenue.cooReport.clientName')" width="220"  prop="customerCode">
            <template slot-scope="scope">
              <popover-select selectType="customer" @input="select" v-model="scope.row.customerCode"  :placeholder="$t('placeholder.searchKeywords')"></popover-select>
            </template>
          </el-table-column>

          <!--認列方式 -->
           <el-table-column align="center" :label="$t('projectRevenue.dataReport.identifyType')" width="100"  prop="identifyType">
            <template slot-scope="scope">
              <el-input  type="text" size="small" v-model="scope.row.identifyType"></el-input>
            </template>
          </el-table-column>

          <!--204結案日--> 
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.endCaseDate')" width="220"  prop="endCaseDate">
            <template slot-scope="scope">
              <el-date-picker v-model="scope.row.endCaseDate" :placeholder="$t('placeholder.content')" class="dateTime yt-table-picker" type="date" :value-format="format" :format="format"/><!--请选择-->
            </template>
          </el-table-column>

          <!--預計開始日--> 
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.expectedStartDate')" width="220"  prop="expectedStartDate">
            <template slot-scope="scope">
              <el-date-picker v-model="scope.row.expectedStartDate" :placeholder="$t('placeholder.content')" class="dateTime yt-table-picker" type="date" :value-format="format" :format="format"/><!--请选择-->
            </template>
          </el-table-column>

          
          <!--預計完工日--> 
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.estimatedCompletionDate')" width="220"  prop="estimatedCompletionDate">
            <template slot-scope="scope">
              <el-date-picker v-model="scope.row.estimatedCompletionDate" :placeholder="$t('placeholder.content')" class="dateTime yt-table-picker" type="date" :value-format="format" :format="format"/><!--请选择-->
            </template>
          </el-table-column>

         
          <!--验收日期--> 
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.acceptanceDate')" width="220"  prop="acceptanceDate">
            <template slot-scope="scope">
              <el-date-picker v-model="scope.row.acceptanceDate" :placeholder="$t('placeholder.content')" class="dateTime yt-table-picker" type="date" :value-format="format" :format="format"/><!--请选择-->
            </template>
          </el-table-column>

          <!--認列結算否--> 
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.isIdentifySettle')" width="100"  prop="isIdentifySettle">
            <template slot-scope="scope">
              <el-input  type="text" size="small" v-model="scope.row.isIdentifySettle"></el-input>
            </template>
          </el-table-column>

           <!--收付款完成--> 
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.isPaymentReceived')" width="100"  prop="isPaymentReceived">
            <template slot-scope="scope">
              <el-input  type="text" size="small" v-model="scope.row.isPaymentReceived"></el-input>
            </template>
          </el-table-column>


          <el-table-column align="center" :label="$t('project.completionIncomeCount')"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.completionIncomeCount"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.completionIncomeCount }}</div>
              </div>
            </template>
          </el-table-column>

          <el-table-column align="center" :label="$t('project.completionCostCount')"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.completionCostCount"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.completionCostCount }}</div>
              </div>
            </template>
          </el-table-column>
          <!--能專成本-->
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.projectAbilityCost')"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.projectAbilityCost"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.projectAbilityCost }}</div>
              </div>
            </template>
          </el-table-column>
          <!--能專成本(以前年度)-->
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.projectAbilityCostPastYear')"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.projectAbilityCostPastYear"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.projectAbilityCostPastYear }}</div>
              </div>
            </template>
          </el-table-column>


          <el-table-column align="center" :label="$t('projectRevenue.dataReport.pastYearIncome')"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.pastYearIncome"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.pastYearIncome }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.pastYearCost')"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.pastYearCost"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.pastYearCost }}</div>
              </div>
            </template>
          </el-table-column>

          <el-table-column align="center" :label="$t('projectRevenue.dataReport.contractIncome')"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.contractIncome"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.contractIncome }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.contractCost')"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.contractCost"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.contractCost }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.contractGrossProfit')" prop="contractGrossProfit"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.contractGrossProfit"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.contractGrossProfit }}</div>
              </div>
            </template>
          </el-table-column>

          <el-table-column align="center" :label="$t('projectRevenue.dataReport.sumIdentifyIncome')"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.sumIdentifyIncome"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.sumIdentifyIncome }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.sumIdentifyCost')"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.sumIdentifyCost"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.sumIdentifyCost }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.sumIdentifyProfit')" prop="sumIdentifyProfit"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.sumIdentifyProfit"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.sumIdentifyProfit }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.recognizedIncome')" prop="recognizedIncome"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.recognizedIncome"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.recognizedIncome }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.recognizedCost')" prop="recognizedCost"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
                <div v-check-submit tabindex="0">
                  <el-input style="display: none" type="number" size="small" v-model="scope.row.recognizedCost"></el-input>
                  <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.recognizedCost }}</div>
                </div>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.sumReceivableRequestFunds')" prop="sumReceivableRequestFunds"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.sumReceivableRequestFunds"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.sumReceivableRequestFunds }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.sumReceivablesFunds')" prop="sumReceivablesFunds"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.sumReceivablesFunds"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.sumReceivablesFunds }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.sumPayableRequestFunds')" prop="sumPayableRequestFunds"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.sumPayableRequestFunds"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.sumPayableRequestFunds }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('projectRevenue.dataReport.sumPaymentFunds')" prop="sumPaymentFunds"  min-width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <div v-check-submit tabindex="0">
                <el-input style="display: none" type="number" size="small" v-model="scope.row.sumPaymentFunds"></el-input>
                <div class="box" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{ scope.row.sumPaymentFunds }}</div>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <div v-show="!loading" class="pagination-container">
          <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" background :current-page.sync="listQuery.page" :page-sizes="[10, 20, 30, 50, 100, 200]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
        </div>
      </div>
    </div>


    <el-dialog :title="$t('bu.newData')" :visible.sync="dictDialogVisible" :close-on-click-modal="false" class="yt-dialogForm-box">
      <el-form ref="form" :model="addData" :inline="true" label-width="100px" class="yt-dialogForm">
        <el-form-item label="Year">
          <template>
            <dict-select v-model="addData.dataYear" code="year" :clearable="true"></dict-select>
          </template>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.projectNo')">
          <template>
            <popover-select selectType="project" @input="select" v-model="addData.projectCode"  :placeholder="$t('placeholder.searchKeywords')"></popover-select>
          </template>
        </el-form-item>

        <el-form-item  label="Type">
          <template>
            <dict-select v-model="addData.projectType" code="projectType" clearable></dict-select>
          </template>
        </el-form-item>

        <el-form-item :label="$t('project.completionIncomeCount')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.completionIncomeCount"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.completionIncomeCount}}</div>
          </div>
        </el-form-item>

        <el-form-item :label="$t('project.completionCostCount')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.completionCostCount"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.completionCostCount}}</div>
          </div>
        </el-form-item>

        <el-form-item :label="$t('projectRevenue.dataReport.projectAbilityCost')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.projectAbilityCost"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.projectAbilityCost}}</div>
          </div>
        </el-form-item>

        <el-form-item :label="$t('projectRevenue.dataReport.projectAbilityCostPastYear')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.projectAbilityCostPastYear"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.projectAbilityCostPastYear}}</div>
          </div>
        </el-form-item>

        <el-form-item :label="$t('projectRevenue.dataReport.pastYearIncome')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.pastYearIncome"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.pastYearIncome}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.pastYearCost')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.pastYearCost"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.pastYearCost}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.contractIncome')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.contractIncome"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.contractIncome}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.recognizedIncome')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.recognizedIncome"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.recognizedIncome}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.contractCost')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.contractCost"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.contractCost}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.recognizedCost')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.recognizedCost"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.recognizedCost}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.contractGrossProfit')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.contractGrossProfit"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.contractGrossProfit}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.sumIdentifyIncome')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.sumIdentifyIncome"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.sumIdentifyIncome}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.sumIdentifyCost')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.sumIdentifyCost"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.sumIdentifyCost}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.sumIdentifyProfit')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.sumIdentifyProfit"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.sumIdentifyProfit}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.sumReceivableRequestFunds')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.sumReceivableRequestFunds"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.sumReceivableRequestFunds}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.sumReceivablesFunds')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.sumReceivablesFunds"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.sumReceivablesFunds}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.sumPayableRequestFunds')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.sumPayableRequestFunds"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.sumPayableRequestFunds}}</div>
          </div>
        </el-form-item>
        <el-form-item :label="$t('projectRevenue.dataReport.sumPaymentFunds')">
          <div v-check-submit tabindex="0">
            <el-input style="display: none" type="number" v-model="addData.sumPaymentFunds"></el-input>
            <div class="box1" style="border: 1px solid #dcdfe6;text-align: left" v-format="'#,##0'" :placeholder="$t('placeholder.content')">{{addData.sumPaymentFunds}}</div>
          </div>
        </el-form-item>
        <!--验收日期--> 
        <el-form-item :label="$t('projectRevenue.dataReport.acceptanceDate')">
          <!-- <div v-check-submit tabindex="0"> -->
            <el-input style="display: none" type="text" v-model="addData.acceptanceDate"></el-input>
            <el-date-picker v-model="addData.acceptanceDate" :placeholder="$t('placeholder.content')" class="dateTime yt-table-picker" type="date" :value-format="format" :format="format"/>
          <!-- </div> -->
        </el-form-item>

        <!--204結案日--> 
        <el-form-item :label="$t('projectRevenue.dataReport.endCaseDate')">
          <!-- <div v-check-submit tabindex="0"> -->
            <el-input style="display: none" type="text" v-model="addData.endCaseDate"></el-input>
            <el-date-picker v-model="addData.endCaseDate" :placeholder="$t('placeholder.content')" class="dateTime yt-table-picker" type="date" :value-format="format" :format="format"/>
          <!-- </div> -->
        </el-form-item>

        <!--預計開始日--> 
        <el-form-item :label="$t('projectRevenue.dataReport.expectedStartDate')">
          <!-- <div v-check-submit tabindex="0"> -->
            <el-input style="display: none" type="text" v-model="addData.expectedStartDate"></el-input>
            <el-date-picker v-model="addData.expectedStartDate" :placeholder="$t('placeholder.content')" class="dateTime yt-table-picker" type="date" :value-format="format" :format="format"/>
          <!-- </div> -->
        </el-form-item>

          <!--預計完工日--> 
        <el-form-item :label="$t('projectRevenue.dataReport.estimatedCompletionDate')">
          <!-- <div v-check-submit tabindex="0"> -->
            <el-input style="display: none" type="text" v-model="addData.estimatedCompletionDate"></el-input>
            <el-date-picker v-model="addData.estimatedCompletionDate" :placeholder="$t('placeholder.content')" class="dateTime yt-table-picker" type="date" :value-format="format" :format="format"/>
          <!-- </div> -->
        </el-form-item>


       <!--認列結算否--> 
        <el-form-item :label="$t('projectRevenue.dataReport.isIdentifySettle')">
          <!-- <div v-check-submit tabindex="0"> -->
            <el-input  type="text" size="small" v-model="addData.isIdentifySettle"></el-input>
          <!-- </div> -->
        </el-form-item>

            <!--收付款完成--> 
        <el-form-item :label="$t('projectRevenue.dataReport.isPaymentReceived')">
          <!-- <div v-check-submit tabindex="0"> -->
            <el-input  type="text" size="small" v-model="addData.isPaymentReceived"></el-input>
          <!-- </div> -->
        </el-form-item>
        
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dictDialogVisible = false">{{
          $t("button.cancel")
        }}</el-button>
        <el-button type="primary" @click="insertData">{{
          $t("button.determine")
        }}</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
  import popoverSelect from '@/components/popover-select/index.vue';
  import { getProjectDataEdit, insertProjectDataEditList, savaProjectDataEditList, deleteProjectDataEditList } from '@/api/pmoReport/projectRevenue';
  import YtTableTitle from '@/components/yt-table-title/index';
  import mixins from '@/mixins/yt-table-title';
  import dictSelect from '@/components/Dict/dictValueSelect';
  export default {
    name: 'projectDataEdit',
    mixins: [mixins],
    components: {
      dictSelect,
      popoverSelect,
      YtTableTitle,
      'dict-select': () => import('@/components/Dict/dictValueSelect')
    },
    props: {
      format: {
        // 时间格式
        type: String,
        default: 'yyyy-MM-dd'
      }
    },
    data() {
      return {
        listQuery: {
          order: 'desc', // 降序（desc）/升序（asc）
          orderBy: 'update_time', // 排序字段
          page: 1,
          limit: 10,
          projectCode: '',
          dataYear: ''
        },
        addData: {
          dataYear: '',
          projectCode: '',
          pastYearIncome: ''
        },
        selectionList: [],
        list: [],
        total: 0,
        dictDialogVisible: false,
        loading: false
      };
    },
    mounted() {
      this.getQuery()
    },
    methods: {
      select(val, row) {
        this.addData.projectId = row.id
      },
      // 新增
      insertData() {
        if (!this.addData.dataYear) {
          this.$message({
            message: this.$t('projectRevenue.dataReport.noDataYear'),
            type: 'error'
          })
          return
        }

        if (!this.addData.projectCode) {
          this.$message({
            message: this.$t('projectRevenue.dataReport.noProjectCode'),
            type: 'error'
          })
          return
        }

        insertProjectDataEditList(this.addData).then(res => {
          if (res.status === 200) {
            this.$notify({
              title: this.$t('tips.success'),
              message: this.$t('tips.updateSuccess'),
              type: 'success',
              duration: 2000
            });
            this.dictDialogVisible = false
            this.addData = {}
            this.getData()
          } else {
            this.$notify({
              title: this.$t('bu.tips.fail'),
              message: res.message,
              type: 'warning'
            });
          }
        })
      },
      saveData() {
      
        if (this.selectionList.length <= 0) {
          this.$notify({
            title: this.$t('scheduleManager.progressList.fail'),
            message: this.selectionList.length <= 0 ? this.$t('scheduleManager.progressList.updateTipsOne') : this.$t('scheduleManager.progressList.updateTipsTwo'), // '您还未选择' : '您只能选择一条数据进行编辑修改'
            type: 'warning'
          });
          return;
        }
       this.selectionList[0].projectEngineer=$('#projectEngineer').val();
       this.selectionList[0].projectEngineerId=$('#projectEngineerId').val();

        this.$confirm(this.$t('tips.permanentUpdate'), this.$t('tips.tips'), {
          confirmButtonText: this.$t('tips.determine'),
          cancelButtonText: this.$t('tips.cancel'),
          type: 'warning'
        })
          .then(() => {
            savaProjectDataEditList(this.selectionList).then(() => {
              this.$notify({
                title: this.$t('tips.success'),
                message: this.$t('tips.updateSuccess'),
                type: 'success',
                duration: 2000
              });

              this.getData();
            });
          });
      },
      deleteData() {
        if (this.selectionList.length <= 0) {
          this.$notify({
            title: this.$t('scheduleManager.progressList.fail'),
            message: this.selectionList.length <= 0 ? this.$t('scheduleManager.progressList.updateTipsOne') : this.$t('scheduleManager.progressList.updateTipsTwo'), // '您还未选择' : '您只能选择一条数据进行编辑修改'
            type: 'warning'
          });
          return;
        }

        this.$confirm(this.$t('tips.permanentUpdate'), this.$t('tips.tips'), {
          confirmButtonText: this.$t('tips.determine'),
          cancelButtonText: this.$t('tips.cancel'),
          type: 'warning'
        })
          .then(() => {
            deleteProjectDataEditList(this.selectionList).then(() => {
              this.$notify({
                title: this.$t('tips.success'),
                message: this.$t('tips.updateSuccess'),
                type: 'success',
                duration: 2000
              });

              this.getData();
            });
          });
      },
      handleSelectionChange(val) {
        //  表格序号选中函数
        this.selectionList = val;
      },
      getQuery() {
        const projectDataEditQuery = window.sessionStorage.getItem('projectDataEditQuery');
        if (projectDataEditQuery) {
          this.listQuery = JSON.parse(projectDataEditQuery);
        }
      },
      editData() {
        if (this.selectionList.length <= 0) {
          this.$notify({
            title: this.$t('scheduleManager.progressList.fail'),
            message: this.selectionList.length <= 0 ? this.$t('scheduleManager.progressList.updateTipsOne') : this.$t('scheduleManager.progressList.updateTipsTwo'), // '您还未选择' : '您只能选择一条数据进行编辑修改'
            type: 'warning'
          });
          return;
        }

        editRecognized(this.selectionList).then(() => {
          this.$notify({
            title: this.$t('tips.success'),
            message: this.$t('tips.updateSuccess'),
            type: 'success',
            duration: 2000
          });

          this.getData();
        });
      },
      getData() {
        this.loading = true
        console.log(JSON.stringify(this.listQuery))
        getProjectDataEdit(this.listQuery).then(res => {
          if (res.status === 200) {
            this.list = res.data.rows;
            this.total = res.data.total;
          } else {
            this.$notify({
              title: this.$t('bu.tips.fail'),
              message: res.message,
              type: 'warning'
            });
          }

          this.loading = false
        })
      },
      handleFilter() {
        this.getData();
      },
      reset() {
        this.listQuery = {
          page: 1,
          limit: 10,
          order: 'desc', // 降序（desc）/升序（asc）
          orderBy: 'update_time', // 排序字段
          projectCode: '',
          dataYear: ''
        };
        this.getData();
      },
      handleSizeChange(val) {
        this.listQuery.limit = val;
        this.getData();
      },
      handleCurrentChange(val) {
        this.listQuery.page = val;
        this.getData();
      }
    },
    beforeDestroy() {
      window.sessionStorage.setItem('projectDataEditQuery', JSON.stringify(this.listQuery))
    }
  };
</script>
<style scoped>
  .box{
    /* border: 1px solid #d9d9d9; */
    padding: 0 15px !important;
    height: 36px;
    line-height: 36px;
    text-align: left;
    border-radius: 4px;
    color: #333;
    cursor:text;
    font-size: 12px;
  }
  .box:empty:before{
    content: attr(placeholder);
    color: #c0c4cc;
    font-size: 14px;
  }


  .box1{
    height: 36px;
    line-height: 36px;
    text-align: center;
    border-radius: 4px;
    color: #333;
    cursor:text;
    padding:0 15px;
  }
  .box1:empty:before{
    content: attr(placeholder);
    color: #c0c4cc;
    font-size: 12px;
  }

</style>
